﻿using System.Windows;
using System.Windows.Controls;
using RestaurantBooker.Controls;

namespace RestaurantBooker.View
{
    /// <summary>
    /// Description for OrderDetails.
    /// </summary>
    public partial class OrderDetails : UserControl
    {
        /// <summary>
        /// Initializes a new instance of the OrderDetails class.
        /// </summary>
        public OrderDetails()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var dt = new DateAndTimePicker();
            dt.Width = 80; dt.Height = 30;
            this.LayoutRoot.Children.Add(dt);
        }

        private void DropDownToggle_Click(object sender, RoutedEventArgs e)
        {
            FrameworkElement fe = sender as FrameworkElement;
            AutoCompleteBox acb = null;
            while (fe != null && acb == null)
            {
                fe = System.Windows.Media.VisualTreeHelper.GetParent(fe) as FrameworkElement;
                acb = fe as AutoCompleteBox;
            }
            if (acb != null)
            {
                if (string.IsNullOrEmpty(acb.SearchText))
                {
                    acb.Text = string.Empty;
                }
                acb.IsDropDownOpen = !acb.IsDropDownOpen;
            }

        }
    }
}


